package hn.cch.jdbc;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import javax.sql.DataSource;

/**
 * Created by chench on 2020-5-21.
 */
@Configuration
public class JdbcBean {

    @Autowired
    private DataSource simpleDataSource;

    @Autowired
    private DataSource centerDataSource;

    @Autowired
    private DataSource accessDataSource;

    @Autowired
    private DataSource secretDataSource;


    @Bean(name = "simpleJdbcTemplate")
    public JdbcTemplate simpleJdbcTemplate() {
        return new JdbcTemplate(simpleDataSource);
    }

    @Bean(name = "centerJdbcTemplate")
    public JdbcTemplate centerJdbcTemplate() {
        return new JdbcTemplate(centerDataSource);
    }

    @Bean(name = "accessJdbcTemplate")
    public JdbcTemplate accessJdbcTemplate() {
        return new JdbcTemplate(accessDataSource);
    }

    @Bean(name = "secretJdbcTemplate")
    public JdbcTemplate secretJdbcTemplate() {
        return new JdbcTemplate(secretDataSource);
    }


}
